﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Golf.WebUI.AdminShow.SystemManagement
{
    public partial class AdminGroupsAdd : Golf.WebUI.App_code.ValidateLogin
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtGroupName.Text.Trim().Length == 0)
            {
                strErr += "管理组名称不能为空！\\n";
            }
            if (this.txtGroupIntro.Text.Trim().Length == 0)
            {
                strErr += "管理组描述不能为空！\\n";
            }
            if (this.txtPowerIdList.Text.Trim().Length == 0)
            {
                strErr += "功能模块ID 多个用 分开不能为空！\\n";
            }
            if (!PageValidate.IsDateTime(txtAddTime.Text))
            {
                strErr += "添加时间格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string GroupName = this.txtGroupName.Text;
            string GroupIntro = this.txtGroupIntro.Text;
            string PowerIdList = this.txtPowerIdList.Text;
            DateTime AddTime = DateTime.Parse(this.txtAddTime.Text);

            Golf.Model.Golf_AdminGroups model = new Golf.Model.Golf_AdminGroups();
            model.GroupName = GroupName;
            model.GroupIntro = GroupIntro;
            model.PowerIdList = PowerIdList;
            model.AddTime = AddTime;

            Golf.BLL.Golf_AdminGroups bll = new Golf.BLL.Golf_AdminGroups();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "AdminGroups.aspx");

        } 
    }
}
